const app = getApp();
const https = require('../../utils/https');
Page({

  /**
   * 页面的初始数据
   */
  data: {
    inspector_info: [],
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    var that = this,
    login_status = wx.getStorageSync('login_status');
    if (!login_status || login_status <= 0) {
      wx.navigateTo({
        url: '/pages/grant/grant',
      })
    }
  },

  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    var that = this,
    login_status = wx.getStorageSync('login_status');
  if (!login_status || login_status <= 0) {
    wx.showLoading({
      title: '请先进行登陆',
    })
    setTimeout(() => {
      wx.hideLoading({
        success: (res) => {
          wx.navigateTo({
            url: '/pages/grant/grant',
          })
        },
      })
    }, 1500);
  }else{
    that.getInspectorInfo();
  }
  },

  getInspectorInfo: function(){
    var that = this,
        user_id = wx.getStorageSync('user_id');
    https.post('getInspectorInfo',{user_id: user_id},false,'正在查询').then(res=>{
      that.setData({
        inspector_info: res
      })
    })
  },

  registerEdit(){
    wx.navigateTo({
      url: '/pages/register/register',
    })
  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },

  /**
   * 页面相关事件处理函数--监听用户下拉动作
   */
  onPullDownRefresh: function () {
    this.onShow();
  },
})